package adapter;

import android.content.Context;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.widget.Button;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.PrePareBeans;
import student.andlei.com.student.R;
import utils.StringUtils;

public class PrePareAdapter extends BaseQuickAdapter<PrePareBeans.mlist,BaseViewHolder>{

    private Context context;
    public PrePareAdapter(Context context, int layoutResId, @Nullable List data) {
        super(layoutResId, data);
        this.context = context;
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    protected void convert(BaseViewHolder helper, PrePareBeans.mlist item) {

//        helper.setText(R.id.tv_week, StringUtils.isNull(item.week)?"":item.week);
//        helper.setText(R.id.tv_date, StringUtils.isNull(item.date)?"":item.date);
//        helper.setText(R.id.tv_time, StringUtils.isNull(item.time)?"":item.time);
//        helper.setText(R.id.tv_subject, StringUtils.isNull(item.subject)?"":item.subject);
//        helper.setText(R.id.tv_teacher, StringUtils.isNull(item.teacher)?"":item.teacher);
//        helper.setText(R.id.tv_state, StringUtils.isNull(item.state)?"":item.state);
//        helper.setText(R.id.bt_look, StringUtils.isNull(item.state)?"":item.state);
//        if(helper.getLayoutPosition()%2==0){
//            helper.getView(R.id.Rly_bg).setBackgroundResource(R.color.item_bg);
//        }else {
//            helper.getView(R.id.Rly_bg).setBackgroundResource(R.color.appstyletitlecolor);
//        }
        helper.setText(R.id.tv_week, StringUtils.isNull(item.week)?"":item.week);
        helper.setText(R.id.tv_date, StringUtils.isNull(item.room_date)?"":item.room_date);
        helper.setText(R.id.tv_time, StringUtils.isNull(item.start_time)?"":(item.start_time+"---"+item.end_time));
        helper.setText(R.id.tv_subject, StringUtils.isNull(item.room_name)?"":item.room_name);
        helper.setText(R.id.tv_teacher, StringUtils.isNull(item.teacher_name)?"":item.teacher_name+"老师");
        helper.addOnClickListener(R.id.bt_look);
        TextView tv =  helper.getView(R.id.tv_state);
        Button  bt = helper.getView(R.id.bt_look);
        //0:表示未预习，1:表示已经预习
        if(item.is_prepare.trim().equals("0")){
            tv.setText("待预习");
            tv.setTextColor(context.getResources().getColor(R.color.btyellow_font));
            bt.setBackgroundResource(R.drawable.bt_yellow_border);
            bt.setText("预习");
            bt.setTextColor(0xFFFFB82F);

        }else {
            tv.setText("已预习");
            tv.setTextColor(context.getResources().getColor(R.color.btfont_color));
            bt.setBackgroundResource(R.drawable.bt_green_border);
            bt.setText("查看");
            bt.setTextColor(0xFF12B9A0);
        }
//        if(item.bag_id.trim().equals("0")){
//            helper.getView(R.id.bt_look).setVisibility(View.VISIBLE);
//        }else {
//            helper.getView(R.id.bt_look).setVisibility(View.GONE);
//        }
        if(helper.getLayoutPosition()%2==0){
            helper.getView(R.id.Rly_bg).setBackgroundResource(R.color.item_bg);
        }else {
            helper.getView(R.id.Rly_bg).setBackgroundResource(R.color.appstyletitlecolor);
        }
    }


}
